#include "simdata_udpsever.h"

SimData_UdpSever::SimData_UdpSever(QString terminal, QHostAddress address, int port, int hz)
{
    m_Terminal = terminal;
    m_Address = address;
    m_Port = port;
    m_Hz = hz;

    temp = 1;
}

void SimData_UdpSever::run()
{
    m_Timer = new QTimer();
    m_Timer->setInterval(m_Hz);
    connect(m_Timer, SIGNAL(timeout()), this, SLOT(update()));
    m_Timer->start();
    exec();
}

QString SimData_UdpSever::terminal()
{
    return m_Terminal;
}

void SimData_UdpSever::update()
{
    temp++;
    QByteArray msg = QString::number(temp).toLatin1();
    qus.writeDatagram(msg, m_Address, m_Port);
}
